package com.zhipin.hackthon;

import java.util.*;

/**
 * 权益
 */
public class Rights {

    // 权益名 要求唯一
    private String name;

    // 权益城市范围
    private Set<String> citySet;

    // 数量
    private int count;

    public Rights(String name, Set<String> citySet, int count) {
        this.name = name;
        this.citySet = Optional.ofNullable(citySet).map(Collections::unmodifiableSet).orElse(new HashSet<>());
        this.count = count;
    }

    public String getName() {
        return name;
    }

    public Set<String> getCitySet() {
        return citySet;
    }

    public int getCount() {
        return count;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Rights rights = (Rights) o;
        return name.equals(rights.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name);
    }
}
